# In 3rd/mpack/SConstruct

import os
from SCons.Script import *

print("正在构建 MPack 库 (3rd/mpack/SConstruct 正在执行)")

# Import env and lib_dir
Import('env', 'lib_dir')
# Import('env', 'lib_dir', 'root_dir') # If root_dir is needed

mpack_src_files = Glob('*.c')
print("mpack_src_files:", mpack_src_files)

env.Append(CCFLAGS=['-fPIC'])

# Build the dynamic library directly into the specified lib_dir
# variant_dir from the caller will handle the .os files
target_path = os.path.join("", 'libmpack')
print(f"MPack SConstruct: Building library target '{target_path}'")
mpack_lib = env.SharedLibrary(target_path, mpack_src_files) # <--- Explicit target path

if not mpack_lib:
    print("ERROR: Failed to create SCons node for libmpack!")
    Exit(1)

Return('mpack_lib')
